package com.ghca.myinfo3.process.service.impl;

import com.ghca.myinfo3.process.entity.BidApplyForm;
import com.ghca.myinfo3.process.service.IApplyService;
import com.ghca.myinfo3.process.service.ProcessEventListener;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/12/23.
 */
@Service
public class BidApplyService implements IApplyService {


    @Resource
    private RepositoryService repositoryService;

    @Resource
    private TaskService taskService;

    @Resource
    private RuntimeService runtimeService;


    @Override
    @Transactional
    public boolean apply(BidApplyForm form) {
        Map<String, Object> map = new HashMap<>();
        try {
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitioKey(), map);
        }catch (RuntimeException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public String processDefinitioKey() {
        return "process_bid";
    }
}
